Skip to content

chore: remove dead protocol remnant (schema v11), dep bumps, local gate#116

Merged
hawkff merged 9 commits into
mainfrom
chore/pr3-debt-features-deps-dx
Jul 3, 2026
Merged

chore: remove dead protocol remnant (schema v11), dep bumps, local gate#116
hawkff merged 9 commits into
mainfrom
chore/pr3-debt-features-deps-dx

Conversation

@hawkff

@hawkff hawkff commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

Dead-code removal (with an additive, non-destructive schema migration), dependency
bumps, and local developer-experience improvements. Stacked on the performance +
security PR (merge that first).

Changes

  • Remove a vestigial protocol remnant: delete the unused legacy plugin-protocol
    bean and all its dead branches. Its stored column is dropped via an additive
    @DeleteColumn auto-migration (schema v11); non-functional legacy rows of that
    type are purged in the migration. The numeric type id stays reserved so it is never
    reused. Existing stored data is otherwise untouched.
  • Dependency bumps: coroutines and the JVM test framework moved to current
    releases; the test SDK pins are raised toward the app’s target (the newer test
    framework bundles it).
  • Build hygiene: bump the formatter plugin to a configuration-cache-clean release
    so the local format gate no longer needs a workaround flag.
  • Local gate script: add a one-command local verification script (format +
    compile + unit tests, no artifact assembly) and a sample opt-in pre-push hook.

Schema note (must resolve before merge)

The Room schema JSON for v11 is generated by the annotation processor at compile
time. Because this environment does not run a local build, .../SagerDatabase/11.json
is not in the commit yet. It must be taken from the first CI compile and committed
(it must equal the v10 schema minus the dropped column). The prior schema files are
left untouched. The generated identity hash must come from the processor, not be
hand-written.

Testing

  • Reviewed as a diff (CodeRabbit CLI). Compilation, lint, unit, and the migration
    test run in CI.
  • The migration (v10 → v11) and the dependency bumps should be confirmed on Android
    (existing stored data survives; the app opens cleanly) before merge.

Held for a follow-up (device session, not in this PR)

  • Larger refactors, the main-thread-database removal, persistent per-profile usage
    stats, and a couple of on-device verifications were intentionally deferred: their
    acceptance requires on-device / full-build verification that isn’t available here.

Greptile Summary

This PR removes the vestigial Matsuri "Neko Plugin" protocol: deletes NekoBean.java, strips every TYPE_NEKO code path from ProxyEntity, KryoConverters, TypeMap, ConfigurationFragment, and Protocols, and drops the nekoBean column from proxy_entities via a Room v11 auto-migration that also purges any lingering type=999 rows. Dependency bumps (kotlinx-coroutines 1.11.0, Robolectric 4.16.1, Spotless 7.0.4) and a new scripts/verify.sh local gate round out the change.

  • Schema migration (v10 → v11): @DeleteColumn on proxy_entities.nekoBean is paired with an onPostMigrate delete of all rows with type = 999. The schema JSON for v11 is now committed and the identityHash is present, resolving the previously flagged blocker. The migration path is additive and non-destructive to all other existing data.
  • Dead-code removal: All branches guarded by nekoBean != null or TYPE_NEKO are cleanly removed across six files; TYPE_NEKO = 999 is kept as a reserved constant with a clear comment to prevent id reuse.
  • Developer tooling: scripts/verify.sh (format → compile → unit tests, no APK assembly) and a sample opt-in pre-push hook are added with mode 100755, addressing the previous permission issue.

Confidence Score: 5/5

Safe to merge after CI confirms the Room KSP build passes with the committed 11.json hash.

The dead-code removal is thorough and consistent across all six affected files. The migration is additive — it only drops an unused column and purges non-functional rows; existing user data for all real protocols is untouched. Both previously flagged blockers (missing schema JSON, non-executable scripts) have been addressed in follow-up commits.

SagerDatabase.kt and 11.json — the migration spec and schema file are the two places where a silent error (wrong identity hash or skipped onPostMigrate) would only surface at runtime on a device upgrade.

Important Files Changed

Filename Overview
app/src/main/java/io/nekohasekai/sagernet/database/SagerDatabase.kt Adds schema v11 auto-migration: drops nekoBean column via @DeleteColumn and purges type=999 rows in onPostMigrate. Migration logic is structurally correct but the onPostMigrate delete is untested by any instrumented migration test.
app/schemas/io.nekohasekai.sagernet.database.SagerDatabase/11.json Schema v11 committed (previously a blocker). nekoBean column absent from proxy_entities, consistent with the @DeleteColumn migration. identityHash present in both root and setupQueries; correctness is gated on the KSP processor agreeing at compile time. File lacks a trailing newline.
app/src/main/java/io/nekohasekai/sagernet/database/ProxyEntity.kt Removes nekoBean field and all TYPE_NEKO branches. TYPE_NEKO = 999 constant is retained as a reserved sentinel. requireBean() / displayType() / putBean() are all updated consistently; no dead branches remain.
app/src/main/java/io/nekohasekai/sagernet/fmt/KryoConverters.java Removes nekoDeserialize TypeConverter — consistent with removal of the NekoBean class and the nekoBean column; no remaining references to NekoBean.
app/src/main/java/moe/matsuri/nb4a/proxy/neko/NekoBean.java File deleted. All references have been cleaned up across the codebase; the type id 999 is reserved in ProxyEntity constants.
app/build.gradle.kts Bumps kotlinx-coroutines-android and kotlinx-coroutines-test from 1.8.1 → 1.11.0, and Robolectric from 4.13 → 4.16.1. Version jumps are large but explicitly called out by the PR author.
build.gradle.kts Bumps Spotless from 6.25.0 → 7.0.4 (major version, configuration-cache-clean). Justified by the build hygiene goal.
scripts/verify.sh New local verification gate: runs spotlessKotlinCheck, compileOssDebugKotlin, testOssDebugUnitTest, and stops the Gradle daemon on exit. File is committed as mode 100755 (previous permission issue resolved).
scripts/hooks/pre-push Thin pre-push hook that delegates to scripts/verify.sh; clearly documented as opt-in (not auto-installed). Committed as mode 100755.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant App
    participant Room
    participant RemoveNekoColumn
    participant SQLite

    App->>Room: open database (v10 DB detected)
    Room->>Room: "apply AutoMigration(from=10, to=11)"
    Note over Room: @DeleteColumn drops nekoBean<br/>via table-copy strategy
    Room->>SQLite: CREATE new proxy_entities (without nekoBean)
    Room->>SQLite: INSERT INTO new SELECT ... FROM old
    Room->>SQLite: DROP TABLE old
    Room->>RemoveNekoColumn: onPostMigrate(db)
    RemoveNekoColumn->>SQLite: "DELETE FROM proxy_entities WHERE type = 999"
    RemoveNekoColumn-->>Room: done
    Room->>SQLite: UPDATE room_master_table SET identity_hash
    Room-->>App: database ready (v11)
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant App
    participant Room
    participant RemoveNekoColumn
    participant SQLite

    App->>Room: open database (v10 DB detected)
    Room->>Room: "apply AutoMigration(from=10, to=11)"
    Note over Room: @DeleteColumn drops nekoBean<br/>via table-copy strategy
    Room->>SQLite: CREATE new proxy_entities (without nekoBean)
    Room->>SQLite: INSERT INTO new SELECT ... FROM old
    Room->>SQLite: DROP TABLE old
    Room->>RemoveNekoColumn: onPostMigrate(db)
    RemoveNekoColumn->>SQLite: "DELETE FROM proxy_entities WHERE type = 999"
    RemoveNekoColumn-->>Room: done
    Room->>SQLite: UPDATE room_master_table SET identity_hash
    Room-->>App: database ready (v11)
Loading

Reviews (10): Last reviewed commit: "chore(db): commit generated Room schema ..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately summarizes the main changes: dead protocol removal, schema v11 migration, dependency bumps, and a local verification gate.
Description check ✅ Passed The description is directly related to the changeset and matches the protocol removal, schema migration, dependency bumps, and tooling updates.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

AutoMigration(from = 7, to = 8),
AutoMigration(from = 8, to = 9),
AutoMigration(from = 9, to = 10),
AutoMigration(from = 10, to = 11, spec = SagerDatabase.RemoveNekoColumn::class),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Missing Room schema JSON for v11

app/schemas/io.nekohasekai.sagernet.database.SagerDatabase/11.json is absent from this commit. Room's KSP processor generates it on the first compile, but without it being committed:

  • MigrationTestHelper.createDatabase(TEST_DB, 11) in any future instrumented test cannot locate the schema and will throw FileNotFoundException
  • Any subsequent auto-migration (v11 → v12) will fail at compile time because Room needs the prior-version schema to validate the from side

The PR description acknowledges this and calls it out as "must resolve before merge." Confirming here so it is tracked as an explicit blocker — the generated file from the first CI compile must be added to the commit before this lands.

Comment thread scripts/verify.sh
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Script committed without executable permission

Both scripts/verify.sh and scripts/hooks/pre-push are committed with mode 100644 instead of 100755. On any fresh clone, ./scripts/verify.sh and the symlinked pre-push hook will fail immediately with "Permission denied" — git cannot exec a non-executable file. Fix: git update-index --chmod=+x scripts/verify.sh scripts/hooks/pre-push.

@hawkff hawkff force-pushed the feat/pr2-perf-security branch from cdfdb76 to b561ec5 Compare July 3, 2026 01:42
@hawkff hawkff force-pushed the chore/pr3-debt-features-deps-dx branch from 6f0e750 to 2c51c87 Compare July 3, 2026 01:42
@hawkff hawkff force-pushed the feat/pr2-perf-security branch from b561ec5 to 846f0f8 Compare July 3, 2026 01:52
@hawkff hawkff force-pushed the chore/pr3-debt-features-deps-dx branch from 2c51c87 to bd69a7a Compare July 3, 2026 01:52
@hawkff hawkff force-pushed the feat/pr2-perf-security branch from 846f0f8 to 7d97488 Compare July 3, 2026 02:01
@hawkff hawkff force-pushed the chore/pr3-debt-features-deps-dx branch from bd69a7a to 467b686 Compare July 3, 2026 02:01
@hawkff hawkff force-pushed the feat/pr2-perf-security branch from 7d97488 to d225538 Compare July 3, 2026 09:09
@hawkff hawkff force-pushed the chore/pr3-debt-features-deps-dx branch 2 times, most recently from eed97fa to 9da095a Compare July 3, 2026 09:18
@hawkff hawkff changed the base branch from feat/pr2-perf-security to main July 3, 2026 11:23
@hawkff hawkff force-pushed the chore/pr3-debt-features-deps-dx branch from 9da095a to 1d64f3c Compare July 3, 2026 11:25
@hawkff hawkff merged commit 4c0ac93 into main Jul 3, 2026
7 checks passed
@hawkff hawkff deleted the chore/pr3-debt-features-deps-dx branch July 3, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant